package com.example.onlineeducation.data.constant

import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.StringDef
import com.example.onlineeducation.R

/**
 * SimpleDes:
 * Creator: Sindi
 * Date: 2022-01-17
 * UseDes:考试
 */
object ExamConstants {
    const val UN_PASSED = "0"//未通过
    const val PASSED = "1"//已通过

    @StringDef(UN_PASSED, PASSED)
    @kotlin.annotation.Retention(AnnotationRetention.SOURCE)
    annotation class Result //是否通过 0-未通过  1-已通过

    @DrawableRes
    fun showResultIcon(@Result str: String): Int {
        return when (str) {
            PASSED -> R.drawable.label_bg_green
            else -> R.drawable.label_bg_red
        }
    }

    fun showResultText(@Result str: String): String {
        return when (str) {
            PASSED -> "已通过"
            else -> "未通过"
        }
    }

    @ColorRes
    fun showResultTextColor(@Result str: String?): Int {
        return when (str) {
            PASSED -> R.color.state_green
            else -> R.color.state_red
        }
    }

    @DrawableRes
    fun showExamResultDetailIcon(@Result str: String?): Int {
        return when (str) {
            PASSED -> R.drawable.ic_result_right2
            else -> R.drawable.ic_result_failure
        }
    }


    fun showExamResultDetailText(@Result str: String?): String {
        return when (str) {
            PASSED -> "通过测试"
            else -> "未通过测试"
        }
    }

}